home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / src / dc1 / var.h < prev    next >
Text File  |  1997-09-09  |  5KB  |  163 lines

  1.  
  2. /*
  3.  *  DC1/VAR.H
  4.  *
  5.  *    (c)Copyright 1992-1997 Obvious Implementations Corp.  Redistribution and
  6.  *    use is allowed under the terms of the DICE-LICENSE FILE,
  7.  *    DICE-LICENSE.TXT.
  8.  *
  9.  *  Note that tracking of global variables within subroutines is accomplished
  10.  *  by generating a dummy semantic variable at the top level of the subroutine.
  11.  *  (VF_DUMMY).  At registerization time if the proper requirements are met
  12.  *  and references satisfied the global is LEAd into an address register.
  13.  *
  14.  *  This, I believe, gives more flexibility than reserving A4 for a small-data
  15.  *  model.  I would much rather have as many address registers available for
  16.  *  register variables as possible.
  17.  */
  18.  
  19. typedef struct Var {
  20.     struct Var *Next;        /*    list of variables?         */
  21.     struct Var *RegVar;     /*    if global placed in register */
  22.     struct Type *Type;
  23.     struct Symbol *Sym;
  24.     struct Stor var_Stor;
  25.     long    Flags;        /*    mainly storage classes        */
  26.     long    LexIdx;        /*    lexical index of declaration    */
  27.     short   Refs;        /*    references to the var    */
  28.     short   RegFlags;        /*    register spec / flags    */
  29.     union {            /*    procedure block or assigned expression      */
  30.     struct BlockStmt *Block;
  31.     struct Exp *AssExp;
  32.     long BOffset;        /*    Offset of bitfield    */
  33.     } u;
  34. } Var;
  35.  
  36. typedef struct ExtVarNode {
  37.     struct ExtVarNode *Next;
  38.     Var *Var;
  39. } ExtVarNode;
  40.  
  41. typedef struct ExtStrNode {
  42.     struct ExtStrNode *Next;
  43.     ubyte *Str;
  44.     long Len;
  45.     long Label;
  46.     long Flags;
  47.     long IIdx;    /* internationalization index */
  48. } ExtStrNode;
  49.  
  50.  
  51. /*
  52.  *  The procedure structure contains information about the procedure
  53.  */
  54.  
  55. typedef struct Proc {
  56.     struct Type *Type;    /*  return type             */
  57.     struct Var    *Vars;    /*  variables representing arguments    */
  58.     short   NumArgs;
  59.     short   Reserved1;
  60.     struct BlockStmt *Base; /*    procedure block             */
  61. } Proc;
  62.  
  63. /*
  64.  *  An expression is a structure which returns a quantity.
  65.  *
  66.  *  Most flag passage requires an ack.    For example, a routine with the
  67.  *  capability to work from condition codes requests that the result be
  68.  *  returned as a condition but only utilizes such if the sub-expression
  69.  *  tells it it can.
  70.  *
  71.  *  To determine when scratch variables may be used to hold a temporary
  72.  *  result (so as not to get blown away by a procedure call), EF_CALL is
  73.  *  propogated backwards in pass 1, then EF_SCROK is propogated forwards
  74.  *  in pass2 (scratch-ok).
  75.  */
  76.  
  77. /*
  78.  *  These are set in pass 0
  79.  */
  80.  
  81. #define EF_RNU        0x0001    /*  child's result will not be used     */
  82. #define EF_COND     0x0002    /*  request branch on condition     */
  83. #define EF_CRES     0x0004    /*  result storage allocated by child    */
  84. #define EF_PRES     0x0008    /*  result storage allocated by parent    */
  85. #define EF_STACK    0x0010    /*  request result be placed on stack (ints only)   */
  86. #define EF_ASSEQ    0x0020    /*  assign-equal (e1 is result)     */
  87.  
  88. #define EF_CALL     0x0040    /*  call made in this sub-tree            */
  89. #define EF_ICAST    0x0080    /*  cast - sub-call already made pass 0!    */
  90.  
  91. /*
  92.  *  These are returned in pass 1
  93.  */
  94.  
  95. #define EF_CONDACK    0x0100    /*  can do request to branch        */
  96. #define EF_STACKACK    0x0200    /*  result was pushed on stack        */
  97. #define EF_ASSPOSINC    0x0400    /*  post incr on assignment        */
  98. #define EF_ASSPREDEC    0x0800    /*  pre dec on assignment        */
  99. #define EF_DIRECT    0x1000
  100. #define EF_LHSASSIGN    0x2000    /*  lhs is for assignment (bitflds) */
  101. #define EF_LHSASSEQ    0x4000
  102. #define EF_SPECIAL    0x8000    /*  special (inline special arg)    */
  103.  
  104. typedef struct Exp {
  105.     void       (*ex_Func)(struct Exp **);   /*    generative procedure        */
  106.     struct Exp    *ex_Next;    /*  used during generation        */
  107.     struct Type *ex_Type;    /*  return type of expression        */
  108.     uword    ex_Flags;
  109.     char    ex_Res1;
  110.     char    ex_Cond;
  111.     short    ex_Token;    /*  generator dependant         */
  112.     short    ex_Res2;
  113.     struct Stor ex_Stor;    /*  machine storage for result (code gen)   */
  114.     long    ex_LexIdx;    /*  line number in input file        */
  115.  
  116.     union {
  117.     struct Exp *Exp;    /*  left hand side            */
  118.     struct Var *Var;    /*  terminating variable        */
  119.     char    *StrConst;
  120.     } u;
  121.  
  122.     union {
  123.     struct Exp *Exp;    /*  right hand side / arglist for p */
  124.     struct Symbol *Sym;    /*  structure element            */
  125.     long    Label;        /*  branch condition            */
  126.     long    StrLen;
  127.     long    Offset;     /*  structure . ->            */
  128.     long    *ConstAry;    /*  linked list of constants        */
  129.     } v;
  130.  
  131.     long ex_LabelT;
  132.     long ex_LabelF;
  133.     void *ex_Reserved1;
  134. } Exp;
  135.  
  136. #define ex_Precedence    ex_Flags
  137. #define ex_Order    ex_Cond
  138.  
  139. #define ex_ExpL     u.Exp
  140. #define ex_Var        u.Var
  141. #define ex_StrConst    u.StrConst
  142.  
  143. #define ex_Offset    v.Offset
  144. #define ex_Symbol    v.Sym
  145. #define ex_ExpR     v.Exp
  146. #define ex_Label    v.Label
  147. /*#define ex_XType      v.XType*/
  148. #define ex_StrLen    v.StrLen
  149. #define ex_ConstAry    v.ConstAry
  150.  
  151. typedef struct PragNode {
  152.     struct PragNode *pn_Next;
  153.     char    *pn_Func;
  154.     char    *pn_Off;
  155.     char    *pn_Ctl;
  156.     short   pn_FuncLen;
  157.     short   pn_OffLen;
  158.     short   pn_CtlLen;
  159.     short   pn_Offset;
  160.     Symbol  *pn_Sym;    /*  base variable   */
  161. } PragNode;
  162.  
  163.